<template>
  <div class="ygfc-wrap" id="ygfc-wrap">
    <el-scrollbar style="height: 700px">
      <div class="ygfc-content">
        <div class="yg-item" v-for="(s,i) of list" :key="i">
          <div class="left">
            <img :src="s.url" alt="" v-if="s.url">
            <div class="no-img" v-else>
              <i class="el-icon-picture"></i>
              <div>照片缺失</div>
            </div>
          </div>
          <div class="right">
            <div class="name">{{ s.name }}</div>
            <div class="zzmm">政治面貌：{{ s.zzmm }}</div>
            <div class="school">毕业院校：{{ s.school }}</div>
            <div class="edu">学历：{{ s.edu }}</div>
            <div class="job">现任岗位：{{ s.job }}</div>
            <div class="number">员工工号：{{ s.number }}</div>
          </div>
        </div>

      </div>
    </el-scrollbar>
  </div>
</template>

<script>


const fs = require('fs');
let xlsx = require('node-xlsx');
// 返回运行文件所在的目录
let sheets = xlsx.parse('C:\\config\\合肥滨湖新区支行员工信息.xlsx');
//let fs=require('fs')
let list = []
sheets.forEach((sheet) => {
  // 读取每行内容
  for (let rowId in sheet['data']) {
    if (rowId > 1 && sheet['data'][rowId].length === 7) {
      let row = sheet['data'][rowId];
      let item = {
        name: row[1],
        zzmm: row[2],
        school: row[3],
        edu: row[4],
        job: row[5],
        number: row[6],
      }
      try {
        let data = fs.readFileSync(`C:\\config\\员工风采\\${row[1]}.jpg`)
        let arrayBufferView = new Uint8Array(data);
        let blob = new Blob([arrayBufferView], {type: "image/jpeg"});
        let urlCreator = window.URL || window.webkitURL;
        item.url = urlCreator.createObjectURL(blob);
      } catch (err) {
        console.log(err)
      }
      list.push(item)
    }
  }
})
export default {
  name: "yuangongfengcai",
  data() {
    return {
      list
    }
  },

  methods: {}

}
</script>

<style lang="scss">

.ygfc-wrap {
  width: 1700px;
  height: 700px;
  margin: 100px auto 0 auto;
  overflow: hidden;

  .el-scrollbar__wrap {
    overflow-x: hidden !important;
  }
}

.ygfc-content {
  width: 1700px;
  height: auto;
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 20px;

}

.yg-item {

  width: 523px;
  height: 325px;
  margin-top: 20px;
  margin-left: 34px;
  box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.3);
  background-color: #E9EAEF;
  border-radius: 10px;
  padding-top: 15px;

  display: flex;

  .left {
    padding-left: 10px;

    .no-img, img {
      box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.3);
      width: 211px;
      height: 295px;
      border-radius: 10px;
    }

    .no-img {
      position: relative;
      text-align: center;
      padding-top: 100px;

      i {
        font-size: 50px;
      }

    }
  }

  .right {
    padding-left: 15px;
    padding-top: 40px;

    .name {
      font-weight: bold;
      font-size: 20px;
    }

    div {
      white-space: nowrap;
      overflow: hidden;
      line-height: 40px;
      text-overflow: ellipsis;
      width: 270px;
    }
  }

}
</style>